package com.ruihu.admin.module.system.department.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruihu.admin.module.system.department.domain.dto.DepartmentQueryDTO;
import com.ruihu.admin.module.system.department.domain.vo.DepartmentVO;
import com.ruihu.admin.module.system.department.domain.entity.DepartmentEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * t_department dao接口
 *
 * @author listen
 * @date 2017/12/19 10:58
 */
@Component
@Mapper
public interface DepartmentDao extends BaseMapper<DepartmentEntity> {


    /**
     * 查询员工列表
     *
     * @param page
     * @param queryDTO
     * @return
     */
    List<DepartmentVO> selectDepartmentByPage(Page page, @Param("queryDTO") DepartmentQueryDTO queryDTO);

    /**
     * 根据部门id，查询此部门直接子部门的数量
     *
     * @param deptId
     * @return int 子部门的数量
     */
    Integer countSubDepartment(@Param("deptId") Long deptId);

    /**
     * 获取全部部门列表
     *
     * @return List<DepartmentVO>
     */
    List<DepartmentVO> listAll();

    /**
     * 获取全部有效部门列表
     *
     * @return List<DepartmentVO>
     */
    List<DepartmentVO> listAllActiveDepartments();

    /**
     * 功能描述: 根据父部门id查询
     *
     * @param
     * @return
     * @auther yandanyang
     * @date 2018/8/25 0025 上午 9:46
     */
    List<DepartmentVO> selectByParentId(@Param("parentDepartmentId") Long parentDepartmentId);

    /**
     * 根据组织部门id获取部门
     *
     * @param orgId
     * @return AjaxResult<DepartmentVO>
     */
    List<DepartmentVO> selectByOrgId(@Param("orgId") Long orgId);

    /**
     * 根据组织部门id和部门名称查询
     *
     * @param orgId
     * @return AjaxResult<DepartmentVO>
     */
    DepartmentVO selectByOrgIdAndName(@Param("orgId") Long orgId,@Param("departmentName")String departmentName);

    /**
     * 根据部门编号查询
     * @param departmentCode
     * @return
     */
    DepartmentVO selectByDepartmentCode(String departmentCode);
}
